namespace hjc {
	export class AStarSystem extends System {

		protected $concerns = [AStar];
		protected execute(entities: Entity[], param?: TimeParam): void {
			entities.forEach(entity => {
				this._toWalk(entity);
			});
		}

		private _toWalk(entity: Entity): void {
			let astar = entity.astar;
			if (!astar.checkPfc()) return;//禁用A星或时机未到
			if (!entity.velocity || entity.velocity.speed <= 0) return;//无位移
			if (!entity.destin) entity.add(Destin);//初始化
			if (notEmptyArr(astar.nodes)) {
				if (!entity.destin.target) {//首次或走完一个节点了
					entity.destin.target = astar.nodes.head();
					astar.nodes.shift();
					if (!notEmptyArr(astar.nodes)) astar.path = null;
				}
			}
		}
	}
}